home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d953.lha / ISAM / examples / Books.rexx < prev    next >
OS/2 REXX Batch file  |  1993-11-28  |  37KB  |  1,516 lines

  1.  
  2. /* Here is a sample ARexx ISAM application */
  3.  
  4. /* This should run the same as the C example */
  5.  
  6.  
  7. /* Here is how the Book and Category records look like from the C Language
  8.  
  9.   struct Book {
  10.      /* 00 */  char  Title [30];
  11.      /* 30 */  char  Author [30];
  12.      /* 60 */  char  Publisher [30];
  13.      /* 90 */  UWORD Copyright;
  14.      /* 92 */  char  Category;
  15.      /* 93 */  char  Form;  /* P-aperback, H-ardCover, T-radePB, C-offeeTable */
  16.      /* 94 */  UWORD Pages;
  17.      /* 96 */  float Value;
  18.   }; /*100 */
  19.  
  20.   struct Category {
  21.      /* 00 */  char Code;
  22.      /* 01 */  char Name [30];
  23.   }; /* 31 */
  24.  
  25. */
  26.  
  27. /*
  28.  trace all
  29. */
  30.  
  31. SIGNAL ON ERROR
  32. SIGNAL ON SYNTAX
  33. SIGNAL ON BREAK_C
  34.  
  35. if ( ~show( 'L', 'rexxsupport.library' ) )
  36.   then
  37.     do
  38.       if ( ~addlib( 'rexxsupport.library', 0, -30, 0 ) )
  39.         then
  40.           do
  41.             say "Couldn't open rexxsupport library."
  42.             exit 10
  43.         end
  44.     end
  45.  
  46. if ( ~show( 'L', 'rexxisam.library' ) )
  47.   then
  48.     do
  49.       if ( ~addlib( 'rexxisam.library', 0, -30, 0 ) )
  50.         then
  51.           do
  52.             say "Couldn't open rexxisam library."
  53.             exit 10
  54.         end
  55.     end
  56.  
  57. ISAM = 1
  58.  
  59.               /* define some constants */
  60. TRUE = 1
  61. FALSE = 0
  62. OK = 0
  63. ERROR_NO_SUCH_RECORD  = 1210
  64. ERROR_DELETED_RECORD  = 1035
  65. ERROR_RECORD_TOO_HIGH = 1235
  66. ERROR_RECORD_EXISTS   = 1225
  67. ERROR_NO_MORE_RECORDS = 1200
  68.  
  69. MAXRECSIZE = 100
  70. MAXKEYSIZE = 30
  71. CLEAR  = '0001 0000'x  /* MEMF_CLEAR - for memory allocation */
  72.  
  73. KeyMem  = 0
  74. ToMem   = 0
  75. FromMem = 0
  76. CatRecMem  = 0
  77. BookRecMem = 0
  78.  
  79. KeyMem  = allocmem( MAXKEYSIZE, CLEAR )
  80. FromMem = allocmem( MAXKEYSIZE, CLEAR )
  81. ToMem   = allocmem( MAXKEYSIZE, CLEAR )
  82.  
  83. CatRecMem  = allocmem( MAXRECSIZE, CLEAR )
  84. BookRecMem = allocmem( MAXRECSIZE, CLEAR )
  85.  
  86. do forever
  87.  
  88.   SpecsFileNameB  = "DATA:Book.specs"
  89.   SpecsFileNameC  = "DATA:BookCat.specs"
  90.  
  91.   BookTypes = "s30 s30 s30 u2 s1 s1 u2 f4"
  92.   BookVars  = "Title Author Publisher Copyright Category Form Pages Value"
  93.   BookFmts  = ' %30.30s %30.30s %30.30s %4u %4.1s "%4.1s "  %6u %8.2lf '
  94.  
  95.   CatTypes = "s1 s30"
  96.   CatVars  = "CatCode CatName"
  97.   CatFmts  = ' "  %.1s " %30.30s '
  98.  
  99.   ISAMHandleB = 0
  100.   error = OpenISAMFile( SpecsFileNameB, TRUE, 'R', TRUE, "ISAMHandleB" )
  101.   if (error ~= OK ) then
  102.     do
  103.       say "Error:" error "opening '" SpecsFileNameB "'"
  104.       break
  105.     end
  106.   ISAMHandleC = 0
  107.   error = OpenISAMFile( SpecsFileNameC, TRUE, 'R', TRUE, "ISAMHandleC" )
  108.   if (error ~= OK ) then
  109.     do
  110.       say "Error:" error "opening '" SpecsFileNameC "'"
  111.       break
  112.     end
  113.  
  114.   do forever
  115.     say ""
  116.     say "1  : Store  Book     5 : Store  Book Category"
  117.     say "2  : Modify Book     6 : Modify Book Category"
  118.     say "3  : Delete Book     7 : Delete Book Category"
  119.     say "4  : List   Books    8 : List   Book Categories"
  120.     say ""
  121.     say "0  : exit"
  122.     say ""
  123.     say "SELECT ?"
  124.  
  125.     parse pull selectit
  126.     say ""
  127.  
  128.  
  129.     if ( selectit = 0 ) then
  130.       break
  131.  
  132.     select
  133.  
  134.       when ( selectit = 1 ) then
  135.         do
  136.          say "Category ?"
  137.          parse upper pull Category
  138.          Category = left( Category, 1 )
  139.  
  140.          error = AssembleRecord( KeyMem, 1, "s1", "Category" )
  141.          if (error ~= OK ) then
  142.            do
  143.              say "Error" error "from AssembleRecord -  main"
  144.              return FALSE
  145.            end
  146.          error = ReadUniqueISAMRecord( ISAMHandleC, 0, KeyMem, ,
  147.                                        FALSE, ' ', "tmpRecNo", CatRecMem )
  148.          select
  149.            when (error = ERROR_NO_SUCH_RECORD ) then
  150.              do
  151.                say "No such Category."
  152.              end
  153.  
  154.            when (error = OK ) then
  155.              do
  156.              end
  157.  
  158.            otherwise 
  159.              do
  160.                say "Error" error "."
  161.              end
  162.          end
  163.  
  164.          if ( error ~= OK ) then
  165.            iterate
  166.  
  167.          say "Title ?"
  168.          parse pull Title
  169.          Title = left( Title, 30, ' ' )
  170.  
  171.          say "Author ?"
  172.          parse pull Author
  173.          Author = left( Author, 30, ' ' )
  174.  
  175.          say "Publisher ?"
  176.          parse pull Publisher
  177.          Publisher = left( Publisher, 30, ' ' )
  178.  
  179.          say "Copyright Year ?"
  180.          parse pull Copyright
  181.  
  182.          say "Form (P/H/T/C) ?"
  183.          parse upper pull Form
  184.          Form = left( Form, 1 )
  185.  
  186.          say "Number of Pages ?"
  187.          parse pull Pages
  188.  
  189.          say "Value ?"
  190.          parse pull Value
  191.  
  192.  
  193.          say "Enter a number to Store Book: ('-1' to abort)"
  194.          parse pull number
  195.          say ""
  196.          if ( number = -1 ) then
  197.            iterate
  198.        
  199.          error = AssembleRecord( BookRecMem, 100, BookTypes, BookVars )
  200.          if (error ~= OK ) then
  201.            do
  202.              say "Error" error " from AssembleRecord - main"
  203.              iterate
  204.            end
  205.  
  206.          error = StoreISAMRecord( ISAMHandleB, BookRecMem, FALSE, ' ', ,
  207.                                   "RecNo" )
  208.          if (error = OK) then
  209.              say "Record# " RecNo
  210.            else
  211.              say "Error:" error " from StoreISAMRecord - book."
  212.          iterate
  213.         end
  214.  
  215.  
  216.       when ( selectit = 2 ) then
  217.         do
  218.          say "Rec# :"
  219.          parse pull RecNo
  220.          say ""
  221.  
  222.          error = ReadISAMRecord( ISAMHandleB, RecNo, FALSE, ' ', BookRecMem )
  223.          select
  224.            when (error = ERROR_DELETED_RECORD) then
  225.              say "That record has been deleted."
  226.  
  227.            when (error = ERROR_RECORD_TOO_HIGH) then
  228.              say "That record number is too high."
  229.  
  230.            when (error = OK) then
  231.              do
  232.              end
  233.  
  234.            otherwise
  235.              say "Error:" error "from ReadISAMRecord - mod. book."
  236.      end
  237.          if ( error ~= OK ) then
  238.            iterate
  239.  
  240.          call EditBook()
  241.            
  242.  
  243.          say "Enter a number to Modify Book: ('-1' to abort)"
  244.          parse pull number
  245.          say ""
  246.          if ( number = -1 ) then
  247.            iterate
  248.        
  249.          error = ModifyISAMRecord( ISAMHandleB, RecNo, BookRecMem )
  250.          if (error = OK) then
  251.              say "Book Modified."
  252.            else
  253.              say "Error:" error "from ModifyISAMRecord - book."
  254.          iterate
  255.         end
  256.  
  257.  
  258.       when ( selectit = 3 ) then
  259.         do
  260.          say "Rec# :"
  261.          parse pull RecNo
  262.          say ""
  263.  
  264.          error = ReadISAMRecord( ISAMHandleB, RecNo, FALSE, ' ', BookRecMem )
  265.          select
  266.            when (error = ERROR_DELETED_RECORD) then
  267.              say "That record has been deleted."
  268.  
  269.            when (error = ERROR_RECORD_TOO_HIGH) then
  270.              say "That record number is too high."
  271.  
  272.            when (error = OK) then
  273.              do
  274.                error = DisAssembleRecord( BookRecMem, 100, BookTypes, BookVars )
  275.                if (error ~= OK ) then
  276.                  do
  277.                    say "Error" error "from DisAssembleRecord - main"
  278.                    return FALSE
  279.                  end
  280.  
  281.                say "Title     : '" || Title || "'"
  282.                say "Author    : '" || Author || "'"
  283.                say "Publisher : '" || Publisher || "'"
  284.                say "Copyright : "  Copyright
  285.                say "Category  : '" || Category || "'"
  286.                say "Form      : '" || Form || "'"
  287.                say "Pages     : "  Pages
  288.                say "Value     : "  Value
  289.                say ""
  290.              end
  291.  
  292.            otherwise
  293.              say "Error:" error "from ReadISAMRecord - del. book."
  294.      end
  295.          if ( error ~= OK ) then
  296.            iterate
  297.  
  298.  
  299.          say "Enter a number to Delete Book: ('-1' to abort)"
  300.          parse pull number
  301.          say ""
  302.          if ( number = -1 ) then
  303.            iterate
  304.        
  305.          error = DeleteISAMRecord( ISAMHandleB, RecNo )
  306.          select
  307.            when (error = ERROR_DELETED_RECORD) then
  308.              say "That record has been deleted."
  309.  
  310.            when (error = ERROR_RECORD_TOO_HIGH) then
  311.              say "That record number is too high."
  312.  
  313.            when (error = OK) then
  314.              do
  315.                say "Record deleted."
  316.              end
  317.  
  318.            otherwise
  319.              say "Error:" error "from DeleteISAMRecord - book."
  320.      end
  321.  
  322.          iterate
  323.         end
  324.  
  325.  
  326.       when ( selectit = 4 ) then
  327.         do
  328.           call ListBooks()
  329.           iterate
  330.         end
  331.  
  332.  
  333.       when ( selectit = 5 ) then
  334.         do
  335.          say "Category Code ?"
  336.          parse upper pull CatCode
  337.          CatCode = left( CatCode, 1 )
  338.  
  339.          say "Category Name ?"
  340.          parse pull CatName
  341.          CatName = left( CatName, 30, ' ' )
  342.  
  343.          error = AssembleRecord( CatRecMem, 31, CatTypes, CatVars )
  344.          if (error ~= OK ) then
  345.            do
  346.              say "Error" error "from AssembleRecord - store cat."
  347.              iterate
  348.            end
  349.  
  350.          say "Enter a number to Store Category: ('-1' to abort)"
  351.          parse pull number
  352.          say ""
  353.          if ( number = -1 ) then
  354.            iterate
  355.        
  356.          error = StoreISAMRecord( ISAMHandleC, CatRecMem, FALSE, ' ', "RecNo" )
  357.          select
  358.            when (error = ERROR_RECORD_EXISTS) then
  359.              say "That Category already exists."
  360.  
  361.            when (error = OK) then
  362.              say "Record# " RecNo
  363.  
  364.            otherwise
  365.              say "Error:" error "from StoreISAMRecord - category"
  366.          end
  367.          iterate
  368.         end
  369.  
  370.  
  371.       when ( selectit = 6 ) then
  372.         do
  373.          say "Category Code ?"
  374.          parse upper pull CatCode
  375.          CatCode = left( CatCode, 1 )
  376.  
  377.          error = AssembleRecord( KeyMem, 1, "s1", "CatCode" )
  378.          if (error ~= OK ) then
  379.            do
  380.              say "Error" error "from AssembleRecord - mod. cat."
  381.              return FALSE
  382.            end
  383.  
  384.          error = ReadUniqueISAMRecord( ISAMHandleC, 0, KeyMem, ,
  385.                                        FALSE, ' ', "RecNo", CatRecMem )
  386.          select
  387.            when (error = ERROR_NO_SUCH_RECORD) then
  388.              say "No such Category."
  389.  
  390.            when (error = OK) then
  391.              do
  392.              end
  393.  
  394.            otherwise
  395.              say "Error:" error " from ReadUniqueISAMRecord - mod. cat."
  396.          end
  397.          if ( error ~= OK ) then
  398.            iterate
  399.  
  400.          error = DisAssembleRecord( CatRecMem, 31, CatTypes, CatVars )
  401.          if (error ~= OK ) then
  402.            do
  403.              say "Error" error "from DisAssembleRecord - mod. cat."
  404.              iterate
  405.            end
  406.  
  407.          say "'" CatName "'" 
  408.          
  409.          say "New Category Code ?"
  410.          parse upper pull CatCode
  411.          CatCode = left( CatCode, 1 )
  412.  
  413.          say "New Category Name ?"
  414.          say "(currently: '" CatName "')"
  415.          parse pull CatName
  416.          CatName = left( CatName, 30, ' ' )
  417.  
  418.          say "Enter a number to Modify Category: ('-1' to abort) "
  419.          parse pull number
  420.          say ""
  421.          if ( number = -1 ) then
  422.            iterate
  423.        
  424.          error = AssembleRecord( CatRecMem, 31, CatTypes, CatVars )
  425.          if (error ~= OK ) then
  426.            do
  427.              say "Error" error "from AssembleRecord - mod. cat."
  428.              iterate
  429.            end
  430.  
  431.          error = ModifyISAMRecord( ISAMHandleC, RecNo, CatRecMem )
  432.          select
  433.            when (error = ERROR_RECORD_EXISTS) then
  434.              say "That Category already exists."
  435.  
  436.            when (error = OK) then
  437.              say "Category Modified."
  438.  
  439.            otherwise
  440.              say "Error:" error "from ModifyISAMRecord - category"
  441.          end
  442.          iterate
  443.         end
  444.  
  445.  
  446.       when ( selectit = 7 ) then
  447.         do
  448.          say "Category Code ?"
  449.          parse upper pull CatCode
  450.          CatCode = left( CatCode, 1 )
  451.  
  452.          error = AssembleRecord( KeyMem, 1, "s1", "CatCode" )
  453.          if (error ~= OK ) then
  454.            do
  455.              say "Error" error "from AssembleRecord - del. cat."
  456.              iterate
  457.            end
  458.  
  459.          error = ReadUniqueISAMRecord( ISAMHandleC, 0, KeyMem, ,
  460.                                        FALSE, ' ', "RecNo", CatRecMem )
  461.          select
  462.            when (error = ERROR_NO_SUCH_RECORD) then
  463.              say "No such Category."
  464.  
  465.            when (error = OK) then
  466.              do
  467.              end
  468.  
  469.            otherwise
  470.              say "Error:" error "from ReadUniqueISAMRecord - del. cat."
  471.          end
  472.          if ( error ~= OK ) then
  473.            iterate
  474.  
  475.          error = DisAssembleRecord( CatRecMem, 31, CatTypes, CatVars )
  476.          if (error ~= OK ) then
  477.            do
  478.              say "Error" error "from DisAssembleRecord - del. cat."
  479.              iterate
  480.            end
  481.  
  482.          say "Category Code: '" || CatCode || "'"
  483.          say "         Name: '" || CatName || "'"
  484.          say ""
  485.  
  486.          say "Enter a number to Delete Category: ('-1' to abort)"
  487.          parse pull number
  488.          say ""
  489.          if ( number = -1 ) then
  490.            iterate
  491.        
  492.          error = DeleteISAMRecord( ISAMHandleC, RecNo )
  493.          select
  494.  
  495.            when (error = OK) then
  496.              say "Category Deleted."
  497.  
  498.            otherwise
  499.              say "Error:" error "from DeleteISAMRecord - category."
  500.          end
  501.  
  502.          iterate
  503.         end
  504.  
  505.       when ( selectit = 8 ) then
  506.         do
  507.          call ListCategories()
  508.          iterate
  509.         end
  510.  
  511.       otherwise
  512.          say "No such option."
  513.          iterate
  514.     end /* select */
  515.  
  516.     iterate
  517.   end  /* do forever - menu */
  518.  
  519.   break
  520. end /* do forever */
  521.  
  522.  
  523.  
  524. /* earlier 'break's fall through to here */
  525.  
  526. /*-------------------------- Cleanup at Shutdown ----------------------------*/
  527.  
  528. END:
  529.  
  530. SYNTAX:
  531. ERROR:
  532. BREAK_C:
  533.  
  534. SIGNAL OFF SYNTAX
  535. SIGNAL OFF ERROR
  536. SIGNAL OFF BREAK_C
  537.  
  538. if ( ( RC ~= 0 ) & ( RC ~= "RC" ) ) then
  539.   do
  540.     if datatype( RC, numeric ) then
  541.       do
  542.         say "Error '"RC"' returned from line '" SIGL "'"
  543.         say ErrorText( RC )
  544.       end
  545.      else
  546.       do
  547.         say "Error returned from line '" SIGL "'"
  548.         say "'" || RC || "'"
  549.       end
  550.     say "Source Line:"
  551.     say "'" || sourceline( SIGL ) || "'"
  552.     say ""
  553.   end
  554.  
  555.  
  556. if ( ISAM = 1 ) then
  557.   do
  558.     if ( ISAMHandleB ~= 0 ) then
  559.       do
  560.         error = CloseISAMFile( ISAMHandleB )
  561.         if ( error ~= OK )
  562.           then say "Error" error "returned closing Book ISAM File."
  563.       end
  564.     if ( ISAMHandleC ~= 0 ) then
  565.       do
  566.         error = CloseISAMFile( ISAMHandleC )
  567.         if ( error ~= OK )
  568.           then say "Error" error "returned closing Book Category ISAM File."
  569.       end
  570.     
  571.     error = EndISAM()
  572.     if ( error ~= OK )
  573.       then say "Error" error "returned Closing ISAM Library."
  574.  
  575.     ISAM = 0    
  576.   end
  577.  
  578.  
  579. if ( KeyMem ~= 0 ) then
  580.   do
  581.     freemem( KeyMem,  MAXKEYSIZE )
  582.     KeyMem = 0
  583.   end
  584. if ( FromMem ~= 0 ) then
  585.   do
  586.     freemem( FromMem, MAXKEYSIZE )
  587.     FromMem = 0
  588.   end
  589. if ( ToMem ~= 0 ) then
  590.   do
  591.     freemem( ToMem,   MAXKEYSIZE )
  592.     ToMem = 0
  593.   end
  594.  
  595. if ( CatRecMem ~= 0 ) then
  596.   do
  597.     freemem( CatRecMem,  MAXRECSIZE )
  598.     CatRecMem = 0
  599.   end
  600. if ( BookRecMem ~= 0 ) then
  601.   do
  602.     freemem( BookRecMem, MAXRECSIZE )
  603.     BookRecMem = 0
  604.   end
  605.  
  606. if ( show( 'L', 'rexxsupport.library' ) )  then
  607.   remlib( 'rexxsupport.library' )
  608.  
  609. if ( show( 'L', 'rexxisam.library' ) ) then
  610.   remlib( 'rexxisam.library' )
  611.  
  612. exit 
  613.  
  614.  
  615.  
  616.  
  617. /*------------------------------ HandlePrefix -------------------------------*/
  618. HandlePrefix: procedure expose prefixLen KeyMem ISAMHandleC CatRecMem ,
  619. FALSE TRUE OK ERROR_NO_SUCH_RECORD
  620.  
  621.   parse arg keyno
  622.  
  623.   select
  624.  
  625.     when (keyno = 0) | (keyno = 1) | (keyno = 2) then
  626.       do
  627.         say "prefix?"
  628.         parse pull prefix
  629.         prefixLen = length( prefix )
  630.         if (prefixLen > 10)
  631.           then
  632.             do
  633.               prefixLen = 10
  634.               prefix = Left( prefix, 10 )
  635.             end
  636.         say "Prefix: '" || prefix || "'"
  637.         say ""
  638.         error = AssembleRecord( KeyMem, 10, "s10", "prefix" )
  639.         if (error ~= OK ) then
  640.           do
  641.             say "Error" error "from AssembleRecord - prefix"
  642.             return FALSE
  643.           end
  644.           
  645.       end
  646.  
  647.     when (keyno = 4) then
  648.       do
  649.         say "prefix?"
  650.         parse pull prefix
  651.         prefixLen = length( prefix )
  652.         if (prefixLen > 2)
  653.           then
  654.             do
  655.               prefixLen = 2
  656.               prefix = Left( prefix, 2 )
  657.             end
  658.         say "Prefix: '" || prefix || "'"
  659.         say ""
  660.         error = AssembleRecord( KeyMem, 2, "s2", "prefix" )
  661.         if (error ~= OK ) then
  662.           do
  663.             say "Error" error "from AssembleRecord - prefix"
  664.             return FALSE
  665.           end
  666.  
  667.             /* ISAM knows Cat key 0 is 1 byte long, so it's OK */
  668.             /* that the prefix has two bytes in it, the 2nd    */
  669.             /* byte will be ignored.                           */
  670.         error = ReadUniqueISAMRecord( ISAMHandleC, 0, KeyMem, ,
  671.                                       FALSE, ' ', "tmpRecNo", CatRecMem )
  672.         select
  673.           when (error = ERROR_NO_SUCH_RECORD ) then
  674.             do
  675.               say "No such Category."
  676.               return FALSE
  677.             end
  678.  
  679.           when (error = OK ) then
  680.             do
  681.             end
  682.  
  683.           otherwise 
  684.             do
  685.               say "Error" error "."
  686.               return FALSE
  687.             end
  688.         end
  689.              
  690.       end
  691.  
  692.     otherwise
  693.       say "Whoops! How did we get here with keyno = " keyno "?"
  694.       return FALSE
  695.  
  696.   end
  697.  
  698.   return TRUE
  699.  
  700.  
  701. /*------------------------------ HandleKey -------------------------------*/
  702. HandleKey: procedure expose KeyMem ISAMHandleC CatRecMem FALSE TRUE OK ,
  703. ERROR_NO_SUCH_RECORD
  704.  
  705.   parse arg keyno
  706.  
  707.   select
  708.  
  709.     when (keyno = 0) | (keyno = 1) | (keyno = 2) then
  710.       do
  711.         say "Key?"
  712.         parse pull key
  713.         key = left( key, 10, ' ' )
  714.         say "Key: '" || key || "'"
  715.         say ""
  716.         error = AssembleRecord( KeyMem, 10, "s10", "key" )
  717.         if (error ~= OK ) then
  718.           do
  719.             say "Error" error "from AssembleRecord - Key"
  720.             return FALSE
  721.           end
  722.       end
  723.  
  724.     when (keyno = 4) then
  725.       do
  726.         say "Key?"
  727.         parse pull key
  728.         key = left( key, 2, ' ' )
  729.         say "Key: '" || key || "'"
  730.         say ""
  731.         error = AssembleRecord( KeyMem, 2, "s2", "key" )
  732.         if (error ~= OK ) then
  733.           do
  734.             say "Error" error "from AssembleRecord - Key"
  735.             return FALSE
  736.           end
  737.         error = ReadUniqueISAMRecord( ISAMHandleC, 0, KeyMem, ,
  738.                                       FALSE, ' ', "tmpRecNo", CatRecMem )
  739.         select
  740.           when (error = ERROR_NO_SUCH_RECORD ) then
  741.             do
  742.               say "No such Category."
  743.               return FALSE
  744.             end
  745.  
  746.           when (error = OK ) then
  747.             do
  748.             end
  749.  
  750.           otherwise 
  751.             do
  752.               say "Error" error "."
  753.               return FALSE
  754.             end
  755.         end
  756.       end
  757.  
  758.  
  759.     when (keyno = 5) then
  760.       do
  761.         say "Key?"
  762.         parse pull key
  763.         key = left( key, 1, ' ' )
  764.         say "Key: '" || key || "'"
  765.         say ""
  766.         error = AssembleRecord( KeyMem, 1, "s1", "key" )
  767.         if (error ~= OK ) then
  768.           do
  769.             say "Error" error "from AssembleRecord - Key"
  770.             return FALSE
  771.           end
  772.       end
  773.  
  774.     when (keyno = 3) | (keyno = 6) then
  775.       do
  776.         say "Key?"
  777.         parse pull key
  778.         say "Key: '" || key || "'"
  779.         say ""
  780.         error = AssembleRecord( KeyMem, 2, "u2", "key" )
  781.         if (error ~= OK ) then
  782.           do
  783.             say "Error" error "from AssembleRecord - Key"
  784.             return FALSE
  785.           end
  786.       end
  787.  
  788.  
  789.     when (keyno = 7) then
  790.       do
  791.         say "Key?"
  792.         parse pull key
  793.         say "Key: '" || key || "'"
  794.         say ""
  795.         error = AssembleRecord( KeyMem, 4, "f4", "key" )
  796.         if (error ~= OK ) then
  797.           do
  798.             say "Error" error "from AssembleRecord - Key"
  799.             return FALSE
  800.           end
  801.       end
  802.  
  803.  
  804.     otherwise
  805.       say "Whoops! How did we get here with keyno = " keyno "?"
  806.       return FALSE
  807.  
  808.   end
  809.  
  810.   return TRUE
  811.  
  812.  
  813. /*----------------------------- HandleRange ------------------------------*/
  814.  
  815. HandleRange: procedure expose FromMem ToMem ISAMHandleC CatRecMem FALSE TRUE ,
  816.                               OK ERROR_NO_SUCH_RECORD
  817.  
  818.   parse arg keyno, itertype
  819.  
  820.   select
  821.  
  822.     when (keyno = 0) | (keyno = 1) | (keyno = 2) then
  823.       do
  824.         if ( (itertype = 1) | ((itertype >= 4) & (itertype <= 9)) ) then
  825.           do
  826.             say "From?"
  827.             parse pull fromkey
  828.             fromkey = left( fromkey, 10, ' ' )
  829.             say "From: '" || fromkey || "'"
  830.             say ""
  831.             error = AssembleRecord( FromMem, 10, "s10", "fromkey" )
  832.             if (error ~= OK ) then
  833.               do
  834.                 say "Error" error "from AssembleRecord - Range"
  835.                 return FALSE
  836.               end
  837.           end
  838.  
  839.         if ( (itertype >= 2) & (itertype <= 7) ) then
  840.           do
  841.             say "To?"
  842.             parse pull tokey
  843.             tokey = left( tokey, 10, ' ' )
  844.             say "To: '" || tokey || "'"
  845.             say ""
  846.             error = AssembleRecord( ToMem, 10, "s10", "tokey" )
  847.             if (error ~= OK ) then
  848.               do
  849.                 say "Error" error "from AssembleRecord - Range"
  850.                 return FALSE
  851.               end
  852.           end
  853.  
  854.       end
  855.  
  856.  
  857.     when (keyno = 4) then
  858.       do
  859.         if ( (itertype = 1) | ((itertype >= 4) & (itertype <= 9)) ) then
  860.           do
  861.             say "From?"
  862.             parse pull fromkey
  863.             fromkey = left( fromkey, 2, ' ' )
  864.             say "From: '" || fromkey || "'"
  865.             say ""
  866.             error = AssembleRecord( FromMem, 2, "s2", "fromkey" )
  867.             if (error ~= OK ) then
  868.               do
  869.                 say "Error" error "from AssembleRecord - Range"
  870.                 return FALSE
  871.               end
  872.             error = ReadUniqueISAMRecord( ISAMHandleC, 0, FromMem, ,
  873.                                           FALSE, ' ', "tmpRecNo", CatRecMem )
  874.             select
  875.               when (error = ERROR_NO_SUCH_RECORD ) then
  876.                 do
  877.                   say "No such Category."
  878.                   return FALSE
  879.                 end
  880.  
  881.               when (error = OK ) then
  882.                 do
  883.                 end
  884.  
  885.               otherwise 
  886.                 do
  887.                   say "Error" error "."
  888.                   return FALSE
  889.                 end
  890.             end
  891.           end
  892.  
  893.  
  894.         if ( (itertype >= 2) & (itertype <= 7) ) then
  895.           do
  896.             say "To?"
  897.             parse pull tokey
  898.             tokey = left( tokey, 2, ' ' )
  899.             say "To: '" || tokey || "'"
  900.             say ""
  901.             error = AssembleRecord( ToMem, 2, "s2", "tokey" )
  902.             if (error ~= OK ) then
  903.               do
  904.                 say "Error" error "from AssembleRecord - Range"
  905.                 return FALSE
  906.               end
  907.             error = ReadUniqueISAMRecord( ISAMHandleC, 0, ToMem, ,
  908.                                           FALSE, ' ', "tmpRecNo", CatRecMem )
  909.             select
  910.               when (error = ERROR_NO_SUCH_RECORD ) then
  911.                 do
  912.                   say "No such Category."
  913.                   return FALSE
  914.                 end
  915.  
  916.               when (error = OK ) then
  917.                 do
  918.                 end
  919.  
  920.               otherwise 
  921.                 do
  922.                   say "Error" error "."
  923.                   return FALSE
  924.                 end
  925.             end
  926.           end
  927.  
  928.       end
  929.  
  930.  
  931.     when (keyno = 5) then
  932.       do
  933.         if ( (itertype = 1) | ((itertype >= 4) & (itertype <= 9)) ) then
  934.           do
  935.             say "From?"
  936.             parse pull fromkey
  937.             say "From: '" || fromkey || "'"
  938.             say ""
  939.             error = AssembleRecord( FromMem, 1, "s1", "fromkey" )
  940.             if (error ~= OK ) then
  941.               do
  942.                 say "Error" error "from AssembleRecord - Range"
  943.                 return FALSE
  944.               end
  945.           end
  946.  
  947.         if ( (itertype >= 2) & (itertype <= 7) ) then
  948.           do
  949.             say "To?"
  950.             parse pull tokey
  951.             say "To: '" || tokey || "'"
  952.             say ""
  953.             error = AssembleRecord( ToMem, 1, "s1", "tokey" )
  954.             if (error ~= OK ) then
  955.               do
  956.                 say "Error" error "from AssembleRecord - Range"
  957.                 return FALSE
  958.               end
  959.           end
  960.       end
  961.  
  962.  
  963.     when (keyno = 3) | (keyno = 6) then
  964.       do
  965.         if ( (itertype = 1) | ((itertype >= 4) & (itertype <= 9)) ) then
  966.           do
  967.             say "From?"
  968.             parse pull fromkey
  969.             say "From: '" || fromkey || "'"
  970.             say ""
  971.             error = AssembleRecord( FromMem, 2, "u2", "fromkey" )
  972.             if (error ~= OK ) then
  973.               do
  974.                 say "Error" error "from AssembleRecord - Range"
  975.                 return FALSE
  976.               end
  977.           end
  978.  
  979.         if ( (itertype >= 2) & (itertype <= 7) ) then
  980.           do
  981.             say "To?"
  982.             parse pull tokey
  983.             say "To: '" || tokey || "'"
  984.             say ""
  985.             error = AssembleRecord( ToMem, 2, "u2", "tokey" )
  986.             if (error ~= OK ) then
  987.               do
  988.                 say "Error" error "from AssembleRecord - Range"
  989.                 return FALSE
  990.               end
  991.           end
  992.       end
  993.  
  994.  
  995.     when (keyno = 7) then
  996.       do
  997.         if ( (itertype = 1) | ((itertype >= 4) & (itertype <= 9)) ) then
  998.           do
  999.             say "From?"
  1000.             parse pull fromkey
  1001.             say "From: '" || fromkey || "'"
  1002.             say ""
  1003.             error = AssembleRecord( FromMem, 4, "f4", "fromkey" )
  1004.             if (error ~= OK ) then
  1005.               do
  1006.                 say "Error" error "from AssembleRecord - Range"
  1007.                 return FALSE
  1008.               end
  1009.           end
  1010.  
  1011.         if ( (itertype >= 2) & (itertype <= 7) ) then
  1012.           do
  1013.             say "To?"
  1014.             parse pull tokey
  1015.             say "To: '" || tokey || "'"
  1016.             say ""
  1017.             error = AssembleRecord( ToMem, 4, "f4", "tokey" )
  1018.             if (error ~= OK ) then
  1019.               do
  1020.                 say "Error" error "from AssembleRecord - Range"
  1021.                 return FALSE
  1022.               end
  1023.           end
  1024.       end
  1025.  
  1026.     otherwise
  1027.       say "Whoops! How did we get here with keyno = " keyno "?"
  1028.       return FALSE
  1029.  
  1030.   end
  1031.  
  1032.   return TRUE
  1033.  
  1034.  
  1035. /*-------------------------------- EditBook ---------------------------------*/
  1036. EditBook: procedure expose BookRecMem OK BookTypes BookVars BookFmts KeyMem ,
  1037.                            ISAMHandleC CatRecMem TRUE FALSE ERROR_NO_SUCH_RECORD
  1038.   do forever
  1039.     error = DisAssembleRecord( BookRecMem, 100, BookTypes, BookVars )
  1040.     if (error ~= OK ) then
  1041.       do
  1042.         say "Error" error "from DisAssembleRecord - EditBook"
  1043.         return
  1044.       end
  1045.       
  1046.     say "Current Record:"
  1047.  
  1048.     say "Title     : '" || Title || "'"
  1049.     say "Author    : '" || Author || "'"
  1050.     say "Publisher : '" || Publisher || "'"
  1051.     say "Copyright : "  Copyright
  1052.     say "Category  : '" || Category || "'"
  1053.     say "Form      : '" || Form || "'"
  1054.     say "Pages     : "  Pages
  1055.     say "Value     : "  Value
  1056.  
  1057.     say ""
  1058.     
  1059.  
  1060.     say "Edit:"
  1061.     say "1 : Title       5 : Category"
  1062.     say "2 : Author      6 : Form"
  1063.     say "3 : Publisher   7 : Pages"
  1064.     say "4 : Copyright   8 : Value"
  1065.     say "0  : end Edit"
  1066.     say ""
  1067.     say "SELECT ?"
  1068.  
  1069.     parse pull selectit
  1070.     say ""
  1071.  
  1072.  
  1073.     if ( selectit = 0 ) then
  1074.       break
  1075.  
  1076.     select
  1077.  
  1078.       when (selectit = 1) then
  1079.         do
  1080.           say "Title ?"
  1081.           parse pull Title
  1082.           Title = left( Title, 30, ' ' )
  1083.         end
  1084.  
  1085.       when (selectit = 2) then
  1086.         do
  1087.           say "Author ?"
  1088.           parse pull Author
  1089.           Author = left( Author, 30, ' ' )
  1090.         end
  1091.  
  1092.       when (selectit = 3) then
  1093.         do
  1094.           say "Publisher ?"
  1095.           parse pull Publisher
  1096.           Publisher = left( Publisher, 30, ' ' )
  1097.         end
  1098.  
  1099.       when (selectit = 4) then
  1100.         do
  1101.           say "Copyright Year ?"
  1102.           parse pull Copyright
  1103.         end
  1104.  
  1105.       when (selectit = 5) then
  1106.         do
  1107.           say "Category ?"
  1108.           parse pull Category
  1109.           Category = left( Category, 2, ' ' )
  1110.  
  1111.           error = AssembleRecord( KeyMem, 2, "s2", "Category" )
  1112.           if (error ~= OK ) then
  1113.             do
  1114.               say "Error" error "from AssembleRecord - EditBook"
  1115.               return
  1116.             end
  1117.           error = ReadUniqueISAMRecord( ISAMHandleC, 0, KeyMem, ,
  1118.                                         FALSE, ' ', "tmpRecNo", CatRecMem )
  1119.           select
  1120.             when (error = ERROR_NO_SUCH_RECORD ) then
  1121.               do
  1122.                 say "No such Category."
  1123.                 return
  1124.               end
  1125.  
  1126.             when (error = OK ) then
  1127.               do
  1128.               end
  1129.  
  1130.             otherwise 
  1131.               do
  1132.                 say "Error" error "reading Category - Editbook."
  1133.                 return
  1134.               end
  1135.           end
  1136.         end
  1137.  
  1138.       when (selectit = 6) then
  1139.         do
  1140.           say "Form (P/H/T/C) ?"
  1141.           parse pull Form
  1142.           Form = left( Form, 1 )
  1143.         end
  1144.  
  1145.       when (selectit = 7) then
  1146.         do
  1147.           say "Number of Pages ?"
  1148.           parse pull Pages
  1149.         end
  1150.  
  1151.       when (selectit = 8) then
  1152.         do
  1153.           say "Value ?"
  1154.           parse pull Value
  1155.         end
  1156.  
  1157.       otherwise
  1158.         do
  1159.           say "No such option."
  1160.           iterate
  1161.         end
  1162.  
  1163.     end
  1164.  
  1165.     error = AssembleRecord( BookRecMem, 100, BookTypes, BookVars )
  1166.     if (error ~= OK ) then
  1167.       do
  1168.         say "Error" error "from AssembleRecord - EditBook"
  1169.         return
  1170.       end
  1171.  
  1172.   end  /* do forever */
  1173.  
  1174.   return
  1175.  
  1176.  
  1177. /*---------------------------- ListCategories ----------------------------*/
  1178. ListCategories : procedure expose ISAMHandleC TRUE FALSE OK ,
  1179.                                   CatRecMem CatTypes CatVars CatFmts ,
  1180.                                   ERROR_NO_MORE_RECORDS
  1181.  
  1182.   error = SetUpISAMIterationRange( ISAMHandleC, 0, 0 )
  1183.   if ( error ~= OK ) then
  1184.     do
  1185.       say "Couldn't set up list."
  1186.       say "Error: ", error
  1187.       return
  1188.     end
  1189.  
  1190.   error = CountISAMRecords( ISAMHandleC, 0, 0, "Count" )
  1191.   if ( error ~= OK ) then
  1192.     do
  1193.       say "Couldn't count Categories."
  1194.       say "Error: ", error
  1195.       return
  1196.     end
  1197.  
  1198.   select
  1199.     when (Count = 0) then say "There are no Categories."
  1200.     when (Count = 1) then say "There is 1 Category."
  1201.     otherwise             say "There are " Count "Categories."
  1202.   end
  1203.     
  1204.   
  1205.   if ( Count = 0 ) then
  1206.     return
  1207.  
  1208.   do forever
  1209.     say ""
  1210.     say "Print the List to someplace other than the screen? (Y/N) "
  1211.     parse upper pull FileDev
  1212.     FileDev = left( FileDev, 1 )
  1213.     if ( ( FileDev = 'Y' ) | ( FileDev = 'N' ) ) then
  1214.       break
  1215.     say "Not an option."
  1216.   end
  1217.  
  1218.   if ( FileDev = 'Y' ) then
  1219.     do
  1220.       say "File/Device Name: "
  1221.       parse pull filename
  1222.       tf = open( "fh", filename, write )
  1223.       if ( tf = FALSE ) then
  1224.         do
  1225.           say "Couldn't open '" filename "' for output."
  1226.           return
  1227.         end
  1228.     end
  1229.  
  1230.   if ( FileDev = 'Y' ) then
  1231.     do
  1232.       call writeln "fh", ""
  1233.       call writeln "fh", "CODE ---------- Category ----------"
  1234.       call writeln "fh", "==================================="
  1235.     end
  1236.    else
  1237.     do
  1238.       say ""
  1239.       say ""
  1240.       say "CODE ---------- Category ----------"
  1241.       say "==================================="
  1242.     end
  1243.  
  1244.  
  1245.   error = OK
  1246.  
  1247.   do while (error = OK )
  1248.     error = ReadNextISAMRecord( ISAMHandleC, 0, ,
  1249.                                 FALSE, ' ', "RecNo", CatRecMem )
  1250.     select
  1251.       when (error = OK) then
  1252.         do
  1253.           error = DisAssembleRecord( CatRecMem, 31, CatTypes, CatVars, CatFmts )
  1254.           if (error ~= OK ) then
  1255.             do
  1256.               say "Error" error "from DisAssembleRecord - List cats."
  1257.               return FALSE
  1258.             end
  1259.           if ( FileDev = 'Y' )
  1260.             then call writeln "fh", CatCode CatName
  1261.             else
  1262.              say CatCode CatName
  1263.         end
  1264.  
  1265.       when (error = ERROR_NO_MORE_RECORDS) then
  1266.         do
  1267.         end
  1268.  
  1269.       otherwise
  1270.         say "Error:" error "from ReadNextISAMRecord - List cats."
  1271.     end      
  1272.  
  1273.   end
  1274.  
  1275.   
  1276.   if ( FileDev = 'Y' ) then
  1277.     do
  1278.       tf = close( "fh" )
  1279.       if ( tf = FALSE ) then
  1280.         do
  1281.           say "Error closing " filename "'"
  1282.         end
  1283.     end
  1284.  
  1285.   return
  1286.  
  1287.  
  1288.  
  1289. /*------------------------------- ListBooks ------------------------------*/
  1290. ListBooks: procedure expose TRUE FALSE OK FromMem ToMem KeyMem ISAMHandleB ,
  1291.                             BookRecMem BookTypes BookVars BookFmts ,
  1292.                             ERROR_NO_MORE_RECORDS
  1293.  
  1294.   do forever 
  1295.     say ""
  1296.     say "List Books by what key:"
  1297.     say "1 : Title       5 : Category/Form"
  1298.     say "2 : Author      6 : Form"
  1299.     say "3 : Publisher   7 : Pages"
  1300.     say "4 : Copyright   8 : Value"
  1301.     say ""
  1302.     say "SELECT ?"
  1303.  
  1304.     parse pull selectit
  1305.     say ""
  1306.     if ( ( selectit < 1 ) | ( selectit > 8 ) ) then
  1307.       do
  1308.         say "No such option."
  1309.         iterate
  1310.       end
  1311.     keyno = selectit - 1
  1312.     break
  1313.   end
  1314.  
  1315.   do forever
  1316.     say ""
  1317.     say "List by:"
  1318.     say "1 : All key values."
  1319.     say "2 : Range of key values."
  1320.     say "3 : One key value."
  1321.     say "4 : Key prefix (keys 1/2/3/5 only)."
  1322.     say ""
  1323.     say "SELECT ?"
  1324.  
  1325.     parse pull selectit
  1326.     say ""
  1327.     if ( ( selectit < 1 ) | ( selectit > 4 ) ) then
  1328.       do
  1329.         say "No such option."
  1330.         iterate
  1331.       end
  1332.     kp1 = keyno+1
  1333.     if ( selectit = 4 ) then
  1334.       select
  1335.         when ( (kp1 = 1) | (kp1 = 2) | (kp1 = 3) | (kp1 = 5) ) then
  1336.           break
  1337.  
  1338.         otherwise
  1339.           do
  1340.             say "Not valid for key selected."
  1341.             iterate
  1342.           end
  1343.       end
  1344.  
  1345.     break
  1346.   end
  1347.  
  1348.  
  1349.   select
  1350.  
  1351.     when ( (selectit = 1) | (selectit = 2) ) then
  1352.       do
  1353.         if (selectit = 1)
  1354.           then itertype = 0
  1355.           else itertype = 7
  1356.  
  1357.         if ( ~HandleRange( keyno, itertype ) ) then
  1358.           return
  1359.  
  1360.         if ( (itertype = 1) | ((itertype >= 4) & (itertype <= 9)) )
  1361.           then FromVar = FromMem
  1362.           else FromVar = 0
  1363.  
  1364.         if ( (itertype >= 2) & (itertype <= 7) )
  1365.           then ToVar = ToMem
  1366.           else ToVar = 0
  1367.         
  1368.         error = SetUpISAMIterationRange( ISAMHandleB, ,
  1369.                                          keyno, itertype, FromVar, ToVar )
  1370.       end
  1371.  
  1372.     when (selectit = 3) then
  1373.       do
  1374.         if ( ~HandleKey( keyno ) ) then
  1375.           return
  1376.         error = SetUpISAMIterationKey( ISAMHandleB, keyno, KeyMem )
  1377.       end
  1378.  
  1379.     when (selectit = 4) then
  1380.       do
  1381.         if ( ~Handleprefix( keyno ) ) then
  1382.           return
  1383.         error = SetUpISAMIterationPrefix( ISAMHandleB, keyno, ,
  1384.                                           KeyMem, prefixLen )
  1385.       end
  1386.  
  1387.   end
  1388.   if ( error ~= OK ) then
  1389.     do
  1390.       say "Couldn't set up list."
  1391.       say "Error:" error
  1392.       return
  1393.     end
  1394.  
  1395.   say "Stop Counting at how many Books: "
  1396.   parse pull CountMax
  1397.   say ""
  1398.  
  1399.   error = CountISAMRecords( ISAMHandleB, keyno, CountMax, "Count" )
  1400.   if ( error ~= OK ) then
  1401.     do
  1402.       say "Couldn't count Books."
  1403.       say "Error:" error
  1404.       return
  1405.     end
  1406.  
  1407.   select
  1408.     when (Count = 0) then say "There are no Books"
  1409.     when (Count = 1) then say "There is 1 Book"
  1410.     otherwise             say "There are" Count "Books"
  1411.   end
  1412.   say "matching that criteria."
  1413.   if ( Count = 0 ) then
  1414.     return
  1415.  
  1416.   do forever
  1417.     say ""
  1418.     say "Print the List to someplace other than the screen? (Y/N) "
  1419.     parse upper pull FileDev
  1420.     FileDev = left( FileDev, 1 )
  1421.     if ( ( FileDev = 'Y' ) | ( FileDev = 'N' ) ) then
  1422.       break
  1423.     say "Not an option."
  1424.     iterate
  1425.   end
  1426.  
  1427.   if ( FileDev = 'Y' ) then
  1428.     do
  1429.       say "File/Device Name: "
  1430.       parse pull filename
  1431.       tf = open( "fh", filename, write )
  1432.       if ( tf = FALSE ) then
  1433.         do
  1434.           say "Couldn't open '" filename "' for output."
  1435.           return
  1436.         end
  1437.     end
  1438.  
  1439.  
  1440.   
  1441.   if ( FileDev = 'Y' ) then
  1442.     do
  1443.       call writeln "fh", ""
  1444.       call writeln "fh", ,
  1445.  "REC# ----------- TITLE ------------ ----------- AUTHOR ------------"
  1446.       call writeln "fh", ,
  1447.  "     --------- PUBLISHER ---------- COPY. CAT. FORM -$VALUE- #PAGES"
  1448.       call writeln "fh", ,
  1449.  "==================================================================="
  1450.     end
  1451.    else
  1452.     do
  1453.       say "" 
  1454.       say "REC# ----------- TITLE ------------ ----------- AUTHOR ------------"
  1455.       say "     --------- PUBLISHER ---------- COPY. CAT. FORM -$VALUE- #PAGES"
  1456.       say "==================================================================="
  1457.     end
  1458.  
  1459.  
  1460.   error = OK
  1461.   do while (error = OK)
  1462.     error = ReadNextISAMRecord( ISAMHandleB, keyno, ,
  1463.                                 FALSE, ' ', "RecNo", BookRecMem )
  1464.     
  1465.     select
  1466.       when (error = OK) then
  1467.         do
  1468.           RecNo = left( RecNo, 4, " " )
  1469.           error = DisAssembleRecord( BookRecMem, 100, BookTypes, ,
  1470.                                      BookVars, BookFmts )
  1471.           if (error ~= OK ) then
  1472.             do
  1473.               say "Error" error "from DisAssembleRecord - ListBooks"
  1474.               return FALSE
  1475.             end
  1476.  
  1477.           if ( FileDev = 'Y' ) then
  1478.             do
  1479.               call writeln "fh", RecNo Title Author
  1480.               call writeln "fh", ,
  1481.                   "    " Publisher Copyright Category Form Value Pages
  1482.               call writeln "fh", ""
  1483.             end
  1484.            else
  1485.             do
  1486.               say RecNo Title Author
  1487.               say "    " Publisher Copyright Category Form Value Pages
  1488.               say ""
  1489.             end
  1490.         end
  1491.  
  1492.       when (error = ERROR_NO_MORE_RECORDS) then
  1493.         do
  1494.         end
  1495.  
  1496.       otherwise
  1497.         say "Error: "error" from ReadNext - ListBooks."
  1498.     end
  1499.  
  1500.   end
  1501.  
  1502.  
  1503.   if ( FileDev = 'Y' ) then
  1504.     do
  1505.       tf = close( "fh" )
  1506.       if ( tf = FALSE ) then
  1507.         do
  1508.           say "Error closing '" filename "'"
  1509.         end
  1510.     end
  1511.  
  1512.   return
  1513.  
  1514.  
  1515.  
  1516.